package com.zhong.gang.applib.utils.permission;

import android.Manifest;
import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;

import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;

import com.yanzhenjie.permission.PermissionListener;

/**
 * 获取SD卡权限
 * */
public  class PermissionSD extends PermissionBase {
    public static final   int PERMISSION_CODE=1000;
    public PermissionSD(Activity activity, PermissionListener permissionListener){
        super(activity,permissionListener);
    }
    public PermissionSD(Fragment fragment, PermissionListener permissionListener){
        super(fragment,permissionListener);
    }
    public  String[] getPermissions(){
        return new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE};
    }


    public static boolean lacksPermissions(Context mContexts) {
        if (lacksPermission(mContexts, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
            return true;
        }
        return false;
    }


    private static boolean lacksPermission(Context mContexts, String permission) {
        return ContextCompat.checkSelfPermission(mContexts, permission) ==
                PackageManager.PERMISSION_DENIED;
    }


    @Override
    public int getPermissCode() {
        return PERMISSION_CODE;
    }

}
